<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>embedme: src/Tracer.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Tracer.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_tracer_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * This file is part of libemb.</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * libemb is free software: you can redistribute it and/or modify</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * it under the terms of the GNU General Public License as published by</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * the Free Software Foundation, either version 3 of the License, or</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * (at your option) any later version.</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * libemb is distributed in the hope that it will be useful,</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> * GNU General Public License for more details.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * You should have received a copy of the GNU General Public License</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * along with libemb.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * Project: Embedme</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> * Author : FergusZeng</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * Email  : cblock@126.com</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> * git    : https://gitee.com/newgolo/embedme.git</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> * Copyright 2014~2020 @ ShenZhen ,China</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment">*******************************************************************************/</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#ifndef __DEBUG_PRINT_H__</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#define __DEBUG_PRINT_H__</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160; </div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_base_type_8h.html">BaseType.h</a>&quot;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_singleton_8h.html">Singleton.h</a>&quot;</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_thread_8h.html">Thread.h</a>&quot;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_thread_util_8h.html">ThreadUtil.h</a>&quot;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_file_util_8h.html">FileUtil.h</a>&quot;</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_date_time_8h.html">DateTime.h</a>&quot;</span></div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &lt;stdio.h&gt;</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &lt;errno.h&gt;</span></div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &lt;string.h&gt;</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &lt;stdarg.h&gt;</span></div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &lt;typeinfo&gt;</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#include &lt;thread&gt;</span></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160; </div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="preprocessor">#define USE_ROS_LOG 0</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160; </div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="preprocessor">#define BUILD_REL_VERSION           0       </span></div>
<div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a51d2ec7e26c90e52a0967b79c0d620fc">   47</a></span>&#160;<span class="preprocessor">//打印等级说明:只有大于或等于当前打印等级的消息才能被打印!</span></div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160; </div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="preprocessor">#define TRACE_LEVEL_DBG             0       </span></div>
<div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="_tracer_8h.html#ad0ba6d6174a3d816380708025ce5cb22">   50</a></span>&#160;<span class="preprocessor">#define TRACE_LEVEL_WARN            1       </span></div>
<div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a81abf4adef27ca1ee16f0568778f958e">   51</a></span>&#160;<span class="preprocessor">#define TRACE_LEVEL_ERR             2       </span></div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a83ec0b2eb9e3c1d45f735972da193e0d">   52</a></span>&#160;<span class="preprocessor">#define TRACE_LEVEL_INFO            3       </span></div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a805a48ca8324f35a46f5251265d7d668">   53</a></span>&#160;<span class="preprocessor">#define TRACE_LEVEL_REL             4       </span></div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="preprocessor"></span><span class="comment">/* __VA_ARGS__宏是C99标准定义的 */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;<span class="preprocessor">#define PRINTF(fmt,...)     do{printf(fmt,##__VA_ARGS__);}while(0)  </span></div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<span class="comment">/* linux标准错误字串 */</span></div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;<span class="preprocessor">#define ERRSTR              (strerror(errno))</span></div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;<span class="preprocessor">#define ERRMSG(err)         (strerror(err))</span></div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160; </div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;<span class="preprocessor">#define TRACE_D(fmt,arg...)         do{libemb::Tracer::getInstance().print(TRACE_LEVEL_DBG,&quot;&lt;D&gt;&quot; fmt,##arg);}while(0)</span></div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;<span class="preprocessor">#define TRACE_E(fmt,arg...)         do{libemb::Tracer::getInstance().print(TRACE_LEVEL_ERR,&quot;&lt;E&gt;&quot; fmt,##arg);}while(0)</span></div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;<span class="preprocessor">#define TRACE_W(fmt,arg...)         do{libemb::Tracer::getInstance().print(TRACE_LEVEL_WARN,&quot;&lt;W&gt;&quot; fmt,##arg);}while(0)</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;<span class="preprocessor">#define TRACE_I(fmt,arg...)         do{libemb::Tracer::getInstance().print(TRACE_LEVEL_INFO,&quot;&lt;I&gt;&quot; fmt,##arg);}while(0)</span></div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="preprocessor">#define TRACE_R(fmt,arg...)         do{libemb::Tracer::getInstance().print(TRACE_LEVEL_REL,&quot;&lt;R&gt;&quot; fmt,##arg);}while(0)</span></div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="preprocessor">#define TRACE_L(uid,fmt,arg...)     do{libemb::Tracer::getInstance().print(uid,&quot;&lt;L%d&gt;&quot; fmt,uid,##arg);}while(0)</span></div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="preprocessor">#define TRACE_DBG(fmt,arg...)       {TRACE_D(&quot;%s,L%d:&quot; fmt,__FUNCTION__,__LINE__,##arg);}   </span></div>
<div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="_tracer_8h.html#ab0d6fc54b462f9f5cd8eec719e77d0af">   69</a></span>&#160;<span class="preprocessor">#define TRACE_WARN(fmt,arg...)      {TRACE_W(&quot;%s,L%d:&quot; fmt,__FUNCTION__,__LINE__,##arg);}   </span></div>
<div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a0866d85379e242af8423181e5beb225f">   70</a></span>&#160;<span class="preprocessor">#define TRACE_ERR(fmt,arg...)       {TRACE_E(&quot;%s,L%d:&quot; fmt,__FUNCTION__,__LINE__,##arg);}   </span></div>
<div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a45055f73487be7356876c9e15530e516">   71</a></span>&#160;<span class="preprocessor">#define TRACE_INFO(fmt,arg...)      {TRACE_I(&quot;%s,L%d:&quot; fmt,__FUNCTION__,__LINE__,##arg);}   </span></div>
<div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a894c4e78e719b0b60aa19c71df0f3f97">   72</a></span>&#160;<span class="preprocessor">#define TRACE_REL(fmt,arg...)       {TRACE_R(&quot;%s:&quot; fmt,__FUNCTION__,##arg);}                </span></div>
<div class="line"><a name="l00073"></a><span class="lineno"><a class="line" href="_tracer_8h.html#af50a5804898f1415b45b75b681f5652c">   73</a></span>&#160;<span class="preprocessor">#define TRACE_LOG(uid,fmt,arg...)   {TRACE_L(uid,&quot;%s,L%d:&quot; fmt,__FUNCTION__,__LINE__,##arg);} </span></div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="preprocessor"></span><span class="comment">/* 带类名的级别打印(仅在C++类中可使用,需要this指针) */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="preprocessor">#define TRACE_DBG_CLASS(fmt,arg...)     {TRACE_D(&quot;%s::%s,L%d:&quot; fmt,this-&gt;className(),__FUNCTION__,__LINE__,##arg);} </span></div>
<div class="line"><a name="l00077"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a52b8a6819e806d0eb624345244a5d965">   77</a></span>&#160;<span class="preprocessor">#define TRACE_WARN_CLASS(fmt,arg...)    {TRACE_W(&quot;%s::%s,L%d:&quot; fmt,this-&gt;className(),__FUNCTION__,__LINE__,##arg);} </span></div>
<div class="line"><a name="l00078"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a024d38ac4da813c9bef2afd222478377">   78</a></span>&#160;<span class="preprocessor">#define TRACE_ERR_CLASS(fmt,arg...)     {TRACE_E(&quot;%s::%s,L%d:&quot; fmt,this-&gt;className(),__FUNCTION__,__LINE__,##arg);} </span></div>
<div class="line"><a name="l00079"></a><span class="lineno"><a class="line" href="_tracer_8h.html#afc210794b4b204fc34850d740983fe60">   79</a></span>&#160;<span class="preprocessor">#define TRACE_INFO_CLASS(fmt,arg...)    {TRACE_I(&quot;%s::%s,L%d:&quot; fmt,this-&gt;className(),__FUNCTION__,__LINE__,##arg);} </span></div>
<div class="line"><a name="l00080"></a><span class="lineno"><a class="line" href="_tracer_8h.html#aec4d1990b387643d1b162ae8c4b4f2d1">   80</a></span>&#160;<span class="preprocessor">#define TRACE_REL_CLASS(fmt,arg...)     {TRACE_R(&quot;%s::%s:&quot; fmt,this-&gt;className(),__FUNCTION__,##arg);}              </span></div>
<div class="line"><a name="l00081"></a><span class="lineno"><a class="line" href="_tracer_8h.html#a59e2b8237c376767dde38a037b7ae92e">   81</a></span>&#160;<span class="preprocessor">#define TRACE_LOG_CLASS(uid,fmt,arg...) {TRACE_L(uid,&quot;%s::%s,L%d:&quot; fmt,this-&gt;className(),__FUNCTION__,__LINE__,##arg);} </span></div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;<span class="preprocessor"></span><span class="comment">/* 下面的宏用于调试跟踪 */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="preprocessor">#define TRACE_IF(condition)         do{if((condition)){TRACE_RED(&quot;if(%s)&lt;@%s,L%d&gt;&quot;,#condition,__FUNCTION__,__LINE__);};}while(0)</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;<span class="preprocessor">#define TRACE_IF_CLASS(condition)   do{if((condition)){TRACE_RED(&quot;if(%s)&lt;@%s::%s,L%d&gt;&quot;,#condition,this-&gt;className(),__FUNCTION__,__LINE__);};}while(0)</span></div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="preprocessor">#define TRACE_NONE(fmt,arg...)</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="preprocessor">#define TRACE_ASSERT(condition)  (if(!(condition)){TRACE_ERR(&quot;Assert !!!&quot;);while(1){libemb::Thread::msleep(100);}})</span></div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160; </div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;<span class="comment">/* 颜色打印 */</span></div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<span class="preprocessor">#define TRACE_RED(fmt,arg...)       do{libemb::Tracer::getInstance().print(TRACE_LEVEL_REL,&quot;&lt;R&gt;\033[31m\033[1m&quot; fmt &quot;\033[0m&quot;,##arg);}while(0)</span></div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;<span class="preprocessor">#define TRACE_GREEN(fmt,arg...)     do{libemb::Tracer::getInstance().print(TRACE_LEVEL_REL,&quot;&lt;R&gt;\033[32m\033[1m&quot; fmt &quot;\033[0m&quot;,##arg);}while(0)</span></div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;<span class="preprocessor">#define TRACE_YELLOW(fmt,arg...)    do{libemb::Tracer::getInstance().print(TRACE_LEVEL_REL,&quot;&lt;R&gt;\033[33m\033[1m&quot; fmt &quot;\033[0m&quot;,##arg);}while(0)</span></div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;<span class="preprocessor">#define TRACE_PINK(fmt,arg...)      do{libemb::Tracer::getInstance().print(TRACE_LEVEL_REL,&quot;&lt;R&gt;\033[35m\033[1m&quot; fmt &quot;\033[0m&quot;,##arg);}while(0)</span></div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;<span class="preprocessor">#define TRACE_CYAN(fmt,arg...)      do{libemb::Tracer::getInstance().print(TRACE_LEVEL_REL,&quot;&lt;R&gt;\033[36m\033[1m&quot; fmt &quot;\033[0m&quot;,##arg);}while(0)</span></div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160; </div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;<span class="preprocessor">#if BUILD_REL_VERSION</span></div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;<span class="preprocessor">#include &quot;TracerLess.h&quot;</span></div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160; </div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;<span class="keyword">namespace </span>libemb{</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;<span class="keyword">class </span>TracerSink;</div>
<div class="line"><a name="l00107"></a><span class="lineno"><a class="line" href="classlibemb_1_1_tracer.html">  107</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlibemb_1_1_tracer.html">Tracer</a>:<span class="keyword">public</span> <a class="code" href="classlibemb_1_1_singleton.html">Singleton</a>&lt;Tracer&gt;,<span class="keyword">public</span> <a class="code" href="classlibemb_1_1_runnable.html">Runnable</a>{</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;<a class="code" href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a>(<a class="code" href="classlibemb_1_1_tracer.html">Tracer</a>)</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;<a class="code" href="_singleton_8h.html#adbe81dabafd4a18fb17e8780c0a9190d">DECL_SINGLETON</a>(<a class="code" href="classlibemb_1_1_tracer.html">Tracer</a>)</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;    ~<a class="code" href="classlibemb_1_1_tracer.html">Tracer</a>();</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_tracer.html#aeea51ea85f94b57071515e261d4fe2c4">print</a>(<span class="keywordtype">int</span> level,<span class="keyword">const</span> <span class="keywordtype">char</span>* format,...);</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_tracer.html#a46db14a31962663e7060a101f695c279">setLevel</a>(<span class="keywordtype">int</span> level);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;    <span class="keywordtype">int</span> <a class="code" href="classlibemb_1_1_tracer.html#a0347bde9f966836353a330ffcee7635e">getLevel</a>();</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_tracer.html#a0a7b36a0d7604bcbf70032735372776a">addSink</a>(std::shared_ptr&lt;TracerSink&gt; sink);</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    <span class="keywordtype">void</span> run();</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    <span class="keywordtype">void</span> sinkMsg();</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> TRACE_MAXLEN =4096;<span class="comment">/* 打印长度最大为4096Bytes,超出后显示省略号 */</span></div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    <a class="code" href="classlibemb_1_1_thread.html">Thread</a> m_thread;</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <a class="code" href="classlibemb_1_1_mutex.html">Mutex</a> m_logMutex;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    std::vector&lt;std::string&gt; m_logVect;</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    <span class="keywordtype">int</span> m_traceLevel{<a class="code" href="_tracer_8h.html#a805a48ca8324f35a46f5251265d7d668">TRACE_LEVEL_INFO</a>};</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    std::vector&lt;std::shared_ptr&lt;TracerSink&gt;&gt; m_sinkVect;</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;};</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160; </div>
<div class="line"><a name="l00149"></a><span class="lineno"><a class="line" href="classlibemb_1_1_tracer_sink.html">  149</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlibemb_1_1_tracer_sink.html">TracerSink</a>{</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;<a class="code" href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a>(<a class="code" href="classlibemb_1_1_tracer_sink.html">TracerSink</a>)</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <a class="code" href="classlibemb_1_1_tracer_sink.html">TracerSink</a>()=<span class="keywordflow">default</span>;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;    <span class="keyword">virtual</span> ~<a class="code" href="classlibemb_1_1_tracer_sink.html">TracerSink</a>()=<span class="keywordflow">default</span>;</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;    <span class="comment">/* 设置日志级别 */</span></div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">void</span> setLevel(<span class="keywordtype">int</span> level){};</div>
<div class="line"><a name="l00162"></a><span class="lineno"><a class="line" href="classlibemb_1_1_tracer_sink.html#ad131f65341bbf9dcaeca74c9be7f92d9">  162</a></span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_tracer_sink.html#ad131f65341bbf9dcaeca74c9be7f92d9">sink</a>(<span class="keywordtype">int</span> uid, <span class="keyword">const</span> std::string&amp; msg)=0;</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;};</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160; </div>
<div class="line"><a name="l00165"></a><span class="lineno"><a class="line" href="classlibemb_1_1_s_t_d_sink.html">  165</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlibemb_1_1_s_t_d_sink.html">STDSink</a>:<span class="keyword">public</span> <a class="code" href="classlibemb_1_1_tracer_sink.html">TracerSink</a>{</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;<a class="code" href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a>(<a class="code" href="classlibemb_1_1_s_t_d_sink.html">STDSink</a>)</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;    <a class="code" href="classlibemb_1_1_s_t_d_sink.html">STDSink</a>();</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;    <span class="keyword">virtual</span> ~<a class="code" href="classlibemb_1_1_s_t_d_sink.html">STDSink</a>();</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_s_t_d_sink.html#a22c0386e73db6b286e8045dfc5077867">sink</a>(<span class="keywordtype">int</span> uid, <span class="keyword">const</span> std::string&amp; msg) <span class="keyword">override</span>;</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;};</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160; </div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;<span class="preprocessor">#if USE_ROS_LOG</span></div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;<span class="keyword">class </span>ROSSink:<span class="keyword">public</span> <a class="code" href="classlibemb_1_1_tracer_sink.html">TracerSink</a>{</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;<a class="code" href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a>(ROSSink)</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;    ROSSink();</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;    <span class="keyword">virtual</span> ~ROSSink();</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;    <span class="keywordtype">void</span> setLevel(<span class="keywordtype">int</span> level) <span class="keyword">override</span>;</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;    <span class="keywordtype">void</span> sink(<span class="keywordtype">int</span> uid, <span class="keyword">const</span> std::string&amp; msg) <span class="keyword">override</span>;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;};</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;}</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160; </div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160; </div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160; </div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="a_tracer_8h_html_a805a48ca8324f35a46f5251265d7d668"><div class="ttname"><a href="_tracer_8h.html#a805a48ca8324f35a46f5251265d7d668">TRACE_LEVEL_INFO</a></div><div class="ttdeci">#define TRACE_LEVEL_INFO</div><div class="ttdef"><b>Definition:</b> Tracer.h:52</div></div>
<div class="ttc" id="a_date_time_8h_html"><div class="ttname"><a href="_date_time_8h.html">DateTime.h</a></div><div class="ttdoc">日期时间</div></div>
<div class="ttc" id="a_singleton_8h_html"><div class="ttname"><a href="_singleton_8h.html">Singleton.h</a></div><div class="ttdoc">单例</div></div>
<div class="ttc" id="aclasslibemb_1_1_mutex_html"><div class="ttname"><a href="classlibemb_1_1_mutex.html">libemb::Mutex</a></div><div class="ttdoc">互斥锁类</div><div class="ttdef"><b>Definition:</b> ThreadUtil.h:43</div></div>
<div class="ttc" id="aclasslibemb_1_1_tracer_html_aeea51ea85f94b57071515e261d4fe2c4"><div class="ttname"><a href="classlibemb_1_1_tracer.html#aeea51ea85f94b57071515e261d4fe2c4">libemb::Tracer::print</a></div><div class="ttdeci">void print(int level, const char *format,...)</div><div class="ttdoc">调试信息打印</div><div class="ttdef"><b>Definition:</b> Tracer.cpp:62</div></div>
<div class="ttc" id="aclasslibemb_1_1_thread_html"><div class="ttname"><a href="classlibemb_1_1_thread.html">libemb::Thread</a></div><div class="ttdef"><b>Definition:</b> Thread.h:56</div></div>
<div class="ttc" id="a_singleton_8h_html_adbe81dabafd4a18fb17e8780c0a9190d"><div class="ttname"><a href="_singleton_8h.html#adbe81dabafd4a18fb17e8780c0a9190d">DECL_SINGLETON</a></div><div class="ttdeci">#define DECL_SINGLETON(InstanceClass)</div><div class="ttdef"><b>Definition:</b> Singleton.h:44</div></div>
<div class="ttc" id="aclasslibemb_1_1_tracer_sink_html"><div class="ttname"><a href="classlibemb_1_1_tracer_sink.html">libemb::TracerSink</a></div><div class="ttdef"><b>Definition:</b> Tracer.h:149</div></div>
<div class="ttc" id="a_base_type_8h_html"><div class="ttname"><a href="_base_type_8h.html">BaseType.h</a></div><div class="ttdoc">基础类型头文件</div></div>
<div class="ttc" id="aclasslibemb_1_1_tracer_html_a0a7b36a0d7604bcbf70032735372776a"><div class="ttname"><a href="classlibemb_1_1_tracer.html#a0a7b36a0d7604bcbf70032735372776a">libemb::Tracer::addSink</a></div><div class="ttdeci">void addSink(std::shared_ptr&lt; TracerSink &gt; sink)</div><div class="ttdoc">增加日志输出器</div><div class="ttdef"><b>Definition:</b> Tracer.cpp:106</div></div>
<div class="ttc" id="aclasslibemb_1_1_tracer_html"><div class="ttname"><a href="classlibemb_1_1_tracer.html">libemb::Tracer</a></div><div class="ttdoc">调试跟踪类</div><div class="ttdef"><b>Definition:</b> Tracer.h:107</div></div>
<div class="ttc" id="aclasslibemb_1_1_s_t_d_sink_html"><div class="ttname"><a href="classlibemb_1_1_s_t_d_sink.html">libemb::STDSink</a></div><div class="ttdef"><b>Definition:</b> Tracer.h:165</div></div>
<div class="ttc" id="a_thread_8h_html"><div class="ttname"><a href="_thread_8h.html">Thread.h</a></div><div class="ttdoc">线程</div></div>
<div class="ttc" id="aclasslibemb_1_1_tracer_html_a0347bde9f966836353a330ffcee7635e"><div class="ttname"><a href="classlibemb_1_1_tracer.html#a0347bde9f966836353a330ffcee7635e">libemb::Tracer::getLevel</a></div><div class="ttdeci">int getLevel()</div><div class="ttdoc">获取打印级别</div><div class="ttdef"><b>Definition:</b> Tracer.cpp:101</div></div>
<div class="ttc" id="aclasslibemb_1_1_runnable_html"><div class="ttname"><a href="classlibemb_1_1_runnable.html">libemb::Runnable</a></div><div class="ttdoc">线程运行体,子类必须重写run方法.</div><div class="ttdef"><b>Definition:</b> Thread.h:44</div></div>
<div class="ttc" id="a_file_util_8h_html"><div class="ttname"><a href="_file_util_8h.html">FileUtil.h</a></div><div class="ttdoc">文件工具类</div></div>
<div class="ttc" id="a_base_type_8h_html_a57e803e49526dc5ba8c1915c68708ae0"><div class="ttname"><a href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a></div><div class="ttdeci">#define DECL_CLASSNAME(ClassName)</div><div class="ttdef"><b>Definition:</b> BaseType.h:176</div></div>
<div class="ttc" id="aclasslibemb_1_1_tracer_html_a46db14a31962663e7060a101f695c279"><div class="ttname"><a href="classlibemb_1_1_tracer.html#a46db14a31962663e7060a101f695c279">libemb::Tracer::setLevel</a></div><div class="ttdeci">void setLevel(int level)</div><div class="ttdoc">设置打印级别</div><div class="ttdef"><b>Definition:</b> Tracer.cpp:92</div></div>
<div class="ttc" id="aclasslibemb_1_1_singleton_html"><div class="ttname"><a href="classlibemb_1_1_singleton.html">libemb::Singleton</a></div><div class="ttdoc">单例模板类</div><div class="ttdef"><b>Definition:</b> Singleton.h:51</div></div>
<div class="ttc" id="aclasslibemb_1_1_tracer_sink_html_ad131f65341bbf9dcaeca74c9be7f92d9"><div class="ttname"><a href="classlibemb_1_1_tracer_sink.html#ad131f65341bbf9dcaeca74c9be7f92d9">libemb::TracerSink::sink</a></div><div class="ttdeci">virtual void sink(int uid, const std::string &amp;msg)=0</div><div class="ttdoc">日志输出</div></div>
<div class="ttc" id="a_thread_util_8h_html"><div class="ttname"><a href="_thread_util_8h.html">ThreadUtil.h</a></div><div class="ttdoc">线程工具</div></div>
<div class="ttc" id="aclasslibemb_1_1_s_t_d_sink_html_a22c0386e73db6b286e8045dfc5077867"><div class="ttname"><a href="classlibemb_1_1_s_t_d_sink.html#a22c0386e73db6b286e8045dfc5077867">libemb::STDSink::sink</a></div><div class="ttdeci">void sink(int uid, const std::string &amp;msg) override</div><div class="ttdoc">日志输出</div><div class="ttdef"><b>Definition:</b> Tracer.cpp:175</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
